<template>
  <div class="app-container">
    <div class="table-page-search-wrapper">
      <el-form :inline="true" label-width="100px">
        <el-row :gutter="18">
          <el-col :md="8" :sm="24">
            <el-form-item label="仓库名称">
              <el-input
                v-model="queryParam.warehouseName"
                placeholder=""
                clearable
                @keyup.enter.native="onSearch"
                @clear="onSearch"
              />
            </el-form-item>
          </el-col>
          <el-col :md="8" :sm="24">
            <span class="table-page-search-submitButtons">
              <el-button v-waves type="primary" icon="el-icon-search" @click="onSearch">
                查询
              </el-button>
              <el-button type="info" icon="el-icon-refresh" @click="reset">
                重置
              </el-button>
            </span>
          </el-col>
        </el-row>
      </el-form>
    </div>

    <div class="table-operator">
      <el-button v-permission="['create']" type="primary" icon="el-icon-plus" @click="$refs.form.open(undefined)">
        新建
      </el-button>
    </div>

    <el-table
      v-loading="loadingData"
      :data="list"
      element-loading-text="Loading"
      fit
      highlight-current-row
      row-key="id"
      @sort-change="appendSorterParam"
    >
      <el-table-column align="center" label="仓库名称">
        <template slot-scope="scope">
          <span>
            {{ scope.row.warehouseName }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="仓库负责人">
        <template slot-scope="scope">
          <span>
            {{ scope.row.iamUserRealname }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="仓库编号">
        <template slot-scope="scope">
          <span>
            {{ scope.row.warehouseNumber }}
          </span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="仓库地址">
        <template slot-scope="scope">
          <span>
            {{ scope.row.warehouseAddress }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
        <template slot-scope="{ row }">
          <el-button v-permission="['update']" type="text" @click="$refs.form.open(row.id)">
            编辑
          </el-button>
          <span v-permission="['detail']" v-permission-again="['update', 'delete']">
            <el-divider direction="vertical" />
          </span>
          <el-button v-permission="['update']" type="text" @click="remove(row.id)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="pagination.total > 0"
      :total="pagination.total"
      :page.sync="pagination.current"
      :limit.sync="pagination.pageSize"
      :style="{ textAlign: 'right' }"
      @pagination="handlePaginationChanged"
    />

    <diboot-form ref="form" @complete="getList" />
  </div>
</template>

<script>
import list from '@/components/diboot/mixins/list'
import dibootForm from './form'
import waves from '@/directive/waves'
export default {
  name: 'WarehouseList',
  directives: { waves },
  components: {
    dibootForm
  },
  mixins: [list],
  data() {
    return {
      baseApi: '/warehouse',
      getListFromMixin: true
    }
  }
}
</script>
<style lang="scss" scoped></style>
